import 'package:flutter/material.dart';
import 'package:flutter_food/core/ext/int_extension.dart';
import 'package:flutter_food/core/model/category_model.dart';
import 'package:flutter_food/ui/pages/meal/meal.dart';

class HomeCategoryItem extends StatelessWidget {
  final CategoryModel _categoryModel;

  HomeCategoryItem(this._categoryModel);

  @override
  Widget build(BuildContext context) {
    var bgColor = _categoryModel.cColor;
    return GestureDetector(
      child: Container(
        decoration: BoxDecoration(
            // 背景
            color: bgColor,
            // 背景颜色透明度
            gradient: LinearGradient(colors: [
              // 透明度
              bgColor.withOpacity(.5),
              bgColor
            ]),
            // 圆角
            borderRadius: BorderRadius.circular(12.px)),
        alignment: Alignment.center,
        child: Text(_categoryModel.title,
            style: Theme.of(context).textTheme.headline5.copyWith(
                  fontWeight: FontWeight.bold,
                )),
      ),
      onTap: () {
        Navigator.of(context)
            .pushNamed(MealScreen.routeName, arguments: _categoryModel);
      },
    );
  }
}
